#!/bin/bash

echo "=========================================="
echo "验收单和项目合同表ID字段类型修改工具"
echo "=========================================="
echo ""
echo "此脚本将修改以下表的ID字段类型："
echo "- project_acceptance (验收单表)"
echo "- project_contract (项目合同表)"
echo "- acceptance_member (验收成员表)"
echo ""
echo "从 BIGINT(20) 改为 INT"
echo ""
echo "=========================================="
echo ""

read -p "请输入数据库用户名（默认：root）: " input
username=${input:-root}

read -sp "请输入数据库密码: " password
echo ""

read -p "请输入数据库名（默认：kaizeli）: " database_input
database=${database_input:-kaizeli}

echo ""
echo "正在执行SQL脚本..."
echo ""

mysql -u$username -p$password $database < fix_acceptance_contract_id_to_int.sql

if [ $? -eq 0 ]; then
    echo ""
    echo "=========================================="
    echo "修改成功！"
    echo "=========================================="
else
    echo ""
    echo "=========================================="
    echo "修改失败，请检查错误信息"
    echo "=========================================="
fi

